/****
 * Copyright (C) 2006 dNux
 *                                                            ****
 * This program is free software; you can redistribute it and/or *
 * modify under the terms of the GNU General Public License as   *
 * published by the Free Software Foundation;                    *
 * either version 2 of the License.                              *
 *                                                               *
 * This program is distributed in the hope that it will be       *
 * useful, but WITHOUT ANY WARRANTY; without even the implied    *
 * warranty of without even the implied waranty of               *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.          *
 * See the GNU General Public License for more details.          *
 *                                                               *
 * You should have received a copy of the                        *
 * GNU General Public License                                    *
 * along with this program; if not, write to the                 *
 * Free Software Foundation, Inc.,                               *
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. *
 *                                                               *
 ****                                                         ****/

void
argv_new(d_check_t *check)
{
  char **argv=NULL;
  argv = d_argv_new();
  if (! argv) {
    d_check_add(check, D_CHECK_ERROR, "argv::new => argv is NULL.");
  } else {
    d_check_add(check, D_CHECK_OK, "argv::new => argv is not NULL.");
  }
  d_argv_free(&argv);
}

void
argv_free(d_check_t *check)
{
  char **argv;
  argv = d_argv_new();
  if (! argv) {
    d_check_add(check, D_CHECK_ERROR, "argv::free => d_argv_new doesnt work.");
    goto error;
  }
  d_argv_free(&argv);
  if (argv) {
    d_check_add(check, D_CHECK_ERROR, "argv::free => argv is not NULL.");
      goto error;
  }
  d_check_add(check, D_CHECK_OK, "argv::free => argv is NULL.");
 error:
  return;
}

void
argv_add(d_check_t *check)
{
  char **argv=NULL;
  argv = d_argv_new();
  if (! argv) {
    d_check_add(check, D_CHECK_ERROR, "argv::add => argv is NULL");
    goto error;
  }
  d_argv_add(&argv, "lalala");
  d_argv_add(&argv, "lilili");

  if (strcmp(argv[0], "lalala")) {
    d_check_add(check, D_CHECK_ERROR, "argv::add => argv[0] != lalala");
    goto error;
  }
  if (strcmp(argv[1], "lilili")) {
    d_check_add(check, D_CHECK_ERROR, "argv::add => argv[1] != lilili");
    goto error;
  }
  
  d_check_add(check, D_CHECK_OK, "argv::add => argv is okay !");
 error:
  if (argv) d_argv_free(&argv);
  return;
}

void
argv_length(d_check_t *check)
{
  char **argv;
  argv = d_argv_new();
  if (! argv) {
    d_check_add(check, D_CHECK_ERROR, "argv::length => argv is NULL");
    goto error;
  }

  d_argv_add(&argv, "lilo");
  d_argv_add(&argv, "lila");
  d_argv_add(&argv, "lilu");

  if (d_argv_length(argv) != 3) {
    d_check_add(check, D_CHECK_ERROR, "argv::length => not equal 3");
    goto error;
  }

  d_check_add(check, D_CHECK_OK, "argv::length => equal 3");
 error:
  if (argv) d_argv_free(&argv);
  return;
}

void
argv_tests(d_check_t *check)
{
  fprintf(stdout, ">> argv_tests <<\n");
  argv_new(check);
  argv_free(check);
  argv_add(check);
  argv_length(check);
  fprintf(stdout, "\n");
}
